package isssr.entity.src;

import java.io.Serializable;

public class OrganizationalGoalVote implements Serializable {

	private static final int MAX_COMMENT_SIZE = 160;
	
	private Long				_voteID;
	private User 				_voteOwner;
	private OrganizationalGoal	_voteTarget;
	private String 				_voteComment;
	private Boolean 			_voteStatus;
	private Boolean 			_valid;
	

	// this constructor is for Hibernate
	private OrganizationalGoalVote() {}
	
	
	public OrganizationalGoalVote(User voteOwner, OrganizationalGoal voteTarget, boolean result, String voteComment) {
		_voteOwner 		= voteOwner;
		_voteTarget 	= voteTarget;
	
		if(voteComment.length() <= MAX_COMMENT_SIZE)
			_voteComment 	= voteComment;
		else
			_voteComment 	= voteComment.substring(0, MAX_COMMENT_SIZE -1);
		
		_voteStatus = new Boolean(result);
		_valid 		= new Boolean(true);
	}

	
	public void invalidateVote() {
		_valid = new Boolean(false);
	}
	
	public void validateVote(boolean result, String voteComment) {
		_voteStatus = new Boolean(result);
		_valid	 	= new Boolean(false);
		
		if(voteComment.length() <= MAX_COMMENT_SIZE)
			_voteComment 	= voteComment;
		else
			_voteComment 	= voteComment.substring(0, MAX_COMMENT_SIZE -1);
	}
	
	
	private Long get_voteID() {
		return _voteID;
	}


	private void set_voteID(Long _voteID) {
		this._voteID = _voteID;
	}
	
	
	private User get_voteOwner() {
		return _voteOwner;
	}


	private void set_voteOwner(User _voteOwner) {
		this._voteOwner = _voteOwner;
	}


	private OrganizationalGoal get_voteTarget() {
		return _voteTarget;
	}


	private void set_voteTarget(OrganizationalGoal _voteTarget) {
		this._voteTarget = _voteTarget;
	}


	private String get_voteComment() {
		return _voteComment;
	}


	private void set_voteComment(String _voteComment) {
		this._voteComment = _voteComment;
	}


	private Boolean get_valid() {
		return _valid;
	}


	private void set_valid(Boolean _valid) {
		this._valid = _valid;
	}


	private Boolean get_voteStatus() {
		return _voteStatus;
	}


	private void set_voteStatus(Boolean _voteStatus) {
		this._voteStatus = _voteStatus;
	}
	
		
}
